473,473 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

unordered list editor javascript

oll3i
679 Contributor
why when i try to make the string(unordered list) to be in a div it apears beside the div
Expand|Select|Wrap|Line Numbers
  1.  function makeUnorderedList(txt){
  2.  var tempText="";    
  3.  var splitResult = txt.split('\n');
  4.  var offer=document.getElementById("editor_displaying_text").innerHTML;
  5.  offer=offer.replace(txt,"");
  6.  
  7.  
  8.  for(i = 0; i < splitResult.length; i++){
  9.     tempText=splitResult[i];
  10.     tempText=tempText.replace(splitResult[i],'<li>'+splitResult[i]+'</li>');
  11.     offer+=tempText;    
  12. }
  13. offer=offer.replace(tempText,'<ul>'+tempText+'</ul>');
  14. document.getElementById("editor_displaying_text").innerHTML = offer;
  15. }
Feb 14 '08 #1
5 2397
acoder
16,027 Recognized Expert Moderator MVP
tempText is the last split item on line 13. You need to replace the whole text (txt) in offer. Remove line 5 and make the replacement on line 13.
Feb 15 '08 #2
oll3i
679 Contributor
hmm i did that but still get the unordered ,list underneath the div and the content of the div doesn't change
Thank You
Feb 15 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
What does the updated code look like?
Feb 15 '08 #4
oll3i
679 Contributor
Expand|Select|Wrap|Line Numbers
  1.  function makeUnorderedList(txt){
  2.  var tempText="";
  3.  var textToRemove="";    
  4.  var splitResult = txt.split('\n');
  5.  var offer=document.getElementById("editor_displaying_text").innerHTML;
  6.  
  7.  
  8.  
  9.  for(i = 0; i < splitResult.length; i++){
  10.     tempText=splitResult[i];
  11.     tempText=tempText.replace(splitResult[i],'<li>'+splitResult[i]+'</li>');
  12.     textToRemove+=tempText;
  13.     offer+=tempText;    
  14. }
  15. offer=offer.replace(textToRemove,'<ul>'+textToRemove+'</ul>');
  16. document.getElementById("editor_displaying_text").innerHTML = offer;
  17. }
  18.  
it only makes unordered list on selected text but it doesn't display it in a div
thank You
Feb 15 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Try alerting txtToRemove, offer and tempText to see if they match for the replace to work.
Feb 16 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: michael | last post by:
Good Morning, I have an unordered list similar to: <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>
5
by: ibiza | last post by:
Hi all, I have a question which I have no ideal of the answer...I am currently working on a web application and at some time, I have a string representing a short text. This could be a simple...
1
by: Eric Jones | last post by:
Hello newsgroup members, I really like CSS, and have created some button like navigation UL/li, etc. I have hover, change color, etc. I am using the "link" as a button, and using ajax and...
3
by: User | last post by:
Hi, Is it possible to transform Ordered/Unordered list into navigation dropdown menus? Is this effect achieved by CSS? or via Javascript? PLease advise Thanks.
0
by: roscoedesign | last post by:
html: http://roscoecreations.com/exitpro/ css: http://roscoecreations.com/exitpro/css/style.css js: http://roscoecreations.com/exitpro/javascript/main.js Recently, I have had some big problems...
5
by: ranyeng | last post by:
Suppose I have an Unordered List in my HTML file: <html> <head> <SCRIPT LANGUAGE="JavaScript"> function remove(){ //code to remove the old elements var...
2
by: torweb | last post by:
I'm using an image for an unordered list, which works fine. The problem is, the image is also appearing in my numbered "ordered list." Here is my code for the unordered list:...and thanks in...
2
by: asc4john | last post by:
When including an unordered list in an unordered list: Should it be included as a "list" item as in: <ul><liitem</ li><ul.... </ul<liitem</li</ul> or included in the LI element as in:...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.